package com.yulongtian.oneProblemEveryDay.month202211.day20221129;

/**
 * https://leetcode.cn/problems/minimum-changes-to-make-alternating-binary-string/
 * 可
 *
 * @author yulongTian
 * @create 2022-11-29 9:49
 */
public class Test01 {
    public static void main(String[] args) {

    }

    public static int minOperations(String s) {
        int len = s.length();
        if (len == 1) {
            return 0;
        }

        int res1 = 0;
        int res2 = 0;

        //0开头

        for (int i = 0; i < s.length(); i++) {
            int temp = s.charAt(i) - '0';
            //应是0
            if ((i & 1) == 0) {
                if (temp == 0) {
                    res1++;
                } else {
                    res2++;
                }
            } else {
                //应是1
                if (temp == 1) {
                    res1++;
                } else {
                    res2++;
                }
            }
        }


        return res1 < res2 ? res1 : res2;
    }


}
